/*
 *  Copyright 2020-2025 the original author or authors.
 *  You cannot use this file unless authorized by the author.
 */

package org.ipig.calc.demo;

import org.ipig.proc.base.calc.CalcRule;
import org.ipig.proc.base.rule.RuleBuilder;
import org.ipig.proc.base.rule.RuleUnit;
import org.ipig.proc.fun.obj.MergeableListObj;

/**
 * MergeableListObj案例
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id: MergeableListObjDemo.java 14 2020-04-17 06:56:19Z ts <comchnts@163.com> $$
 * @since 1.0
 */
public class MergeableListObjDemo implements CalcRule {

    @Override
    public RuleUnit createCalcRule(RuleBuilder ruleBuilder) {
        return ruleBuilder.newInstance("同商户过去100笔交易的涉及的用户号")
                .selectModel("DEMO0001", "IPIG", true)
                .selectKey((model) -> {
                    return model.getKey();//指定维度
                })
                .selectTime((model) -> {
                    return model.getTime();
                })
                .selectMetrics("fromAcct") //指定指标名
                .filter((model) -> {
                    return true;
                })
                .expirePattern("100")
                .action((model) -> {
                    return new MergeableListObj(model.getValue("fromAcct"));
                }).build();
    }
}

